#include "monster.h"

Monster::Monster(Map* m)
{
  map = m;
}

Monster::Monster(Map* m, MTEntry* e)
{
  map = m;
  type = e;
}

Monster::Monster(Map* m, MTEntry* e, int x, int y)
{
  map = m;
  type = e;
  posX = x;
  posY = y;
}

int Monster::getFore()
{
  return type->getFore();
}

int Monster::getBack()
{
  return COLOR_BLACK;
}

char Monster::getSymbol()
{
  return type->getSymbol();
}

bool Monster::isPlayer()
{
  return false;
}

bool Monster::isCreature()
{
  return true;
}

bool Monster::isMonster()
{
  return true;
}

int Monster::getStatus()
{
  return status;
}

void Monster::makeMove()
{
  int r = rand() % 8;
  int x, y;
  switch (r)
  {
    case 0:
      x = posX - 1;
      y = posY - 1;
      break;
    case 1:
      x = posX - 1;
      break;
    case 2:
      x = posX - 1;
      y = posY + 1;
      break;
    case 3:
      y = posY - 1;
      break;
    case 4:
      y = posY + 1;
      break;
    case 5:
      x = posX + 1;
      y = posY - 1;
      break;
    case 6:
      x = posX + 1;
      break;
    case 7:
      x = posX + 1;
      y = posY + 1;
      break;
  }
  if (map->getSpace(x,y)->passable());
    map->moveCreature(ID,x,y); 
  return;
}

int Monster::getID()
{
  return ID;
}

void Monster::setID(int i)
{
  ID = i;
}

string Monster::getName()
{
  return type->getName();
}

int Monster::getX()
{
  return posX;
}

int Monster::getY()
{
  return posY;
}
